<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>关键帧动画 @keyframes</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .rect {
            width: 100px;
            height: 100px;
            background-color: #f00;
            position: fixed;
            animation: moverect 2s infinite;
        }

        @keyframes mymove {
            from { top: 0; left: 0; }
            to { top: 0; left: 200px; }
        }

        @keyframes moverect {
            0% { top: 0; left: 20%; }
            25% { top: 0; left: 80%; }
            50% { top: 80%; left: 80%; }
            75% { top: 80%; left: 20%; }
            100% { top: 0; left: 20%; }
        }
    </style>
</head>
<body>
    <div class="rect"></div>
</body>
</html>